home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
015
/
hpfilter.arc
/
HPFILTER.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-01-18
|
18KB
|
602 lines
;**********************************************************************************
;* This program traps the printer output interrupt (17H), and translates
;* outgoing IBM-style line drawing characters to codes compatible with the
;* HP Laserjet.
;* *
;* *
;* USE: Giving the command "HPFILTER" for the first time will install the *
;* conversion utility, and report "HPFilter installed and running." *
;* Thereafter, giving the "HPFILTER" command will toggle the translation *
;* feature off and on, reporting "HPFilter temporarily deactivated" or *
;* "HPFilter reactivated." *
;* *
;**********************************************************************************
CSEG segment para public 'CODE'
assume cs:CSEG, ds:CSEG
DOS macro fcn_code, location_arg
mov ah, fcn_code
ifnb <location_arg>
mov dx, offset location_arg
endif
int 21H
endm
; The printer interrupt number is 17H.
PRINTER_INTERRUPT equ 17H
SIGNATURE equ 0d6f1H ;not opcodes
ESC equ 1bH
PRINT_MESSAGE equ 09H
SET_VECTOR equ 25H
org 100H ; goes thru EXE2BIN
HOME: jmp START ; skip around all the data space
; Data areas
BIOS_HANDLER dd ? ; address of former int handler
IN_CHAR dw ?
C_STRING DW 0 ;CONTROL STRING IN PROGRESS
BOLD_ON DB 0 ;DO BOLD FACE
;=========================================================================
; This table contains the base address for the character strings that
; will define the graphic characters.
;=========================================================================
HP_BASE equ this byte
dw offset hpc179
dw offset hpc180
dw offset hpc181
dw offset hpc182
dw offset hpc183
dw offset hpc184
dw offset hpc185
dw offset hpc186
dw offset hpc187
dw offset hpc188
dw offset hpc189
dw offset hpc190
dw offset hpc191
dw offset hpc192
dw offset hpc193
dw offset hpc194
dw offset hpc195
dw offset hpc196
dw offset hpc197
dw offset hpc198
dw offset hpc199
dw offset hpc200
dw offset hpc201
dw offset hpc202
dw offset hpc203
dw offset hpc204
dw offset hpc205
dw offset hpc206
dw offset hpc207
dw offset hpc208
dw offset hpc209
dw offset hpc210
dw offset hpc211
dw offset hpc212
dw offset hpc213
dw offset hpc214
dw offset hpc215
dw offset hpc216
dw offset hpc217
dw offset hpc218
dw offset hpc219
dw offset hpc220
dw offset hpc221
dw offset hpc222
dw offset hpc223
;=========================================================================
; These strings are definitions for the PC graphic characters as they
; are printed on the HP LazerJet + with out a ROM cartridge. They are
; layed out on a 30x50 grid with the entry at 0,36 and extit at 31,36.
; This corresponds to the character figure given in the tech manual.
; Each line segment is 5 dots wide.
;
; The periods '.' in the data below are to assist in alignment, they
; are ignored for output, and may be removed
;=========================================================================
ESC equ 27
; │
hpc179 db ESC,"*p+14x-36Y.*c3a50bP"
db ESC,"*p+16x+36Y",0
; ┤
hpc180 db ESC,"*p+14x-36Y.*c3a50bP"
db ESC,"*p-14x+20Y.*c17a3bP"
db ESC,"*p+30x+16Y",0
; ╡
hpc181 db ESC,"*p+14x-36Y.*c3a50bP"
db ESC,"*p-14x+15Y.*c17a3bP"
db ESC,"*p+10Y.....*c17a3bP"
db ESC,"*p+30x+11Y",0
; ╢
hpc182 db ESC,"*p+9x-36Y..*c3a50bP"
db ESC,"*p+10X.....*c3a50bP"
db ESC,"*p-19x+20Y.*c9a3bP"
db ESC,"*p+30x+16Y",0
; ╖
hpc183 db ESC,"*p-16Y.....*c22a3bP"
db ESC,"*p+9X......*c3a30bP"
db ESC,"*p+10X.....*c3a30bP"
db ESC,"*p+11x+16Y",0
; ╕
hpc184 db ESC,"*p+14x-21Y.*c3a35bP"
db ESC,"*p-14X.....*c14a3bP"
db ESC,"*p+10Y.....*c14a3bP"
db ESC,"*p+30x+11Y",0
; ╣
hpc185 db ESC,"*p+9x-36Y..*c3a18bP"
db ESC,"*p+25Y.....*c3a25bP"
db ESC,"*p-9x-10Y..*c12a3bP"
db ESC,"*p+10Y.....*c12a3bP"
db ESC,"*p+19x-25Y.*c3a50bP"
db ESC,"*p+11x+36Y",0
; ║
hpc186 db ESC,"*p+9x-36Y..*c3a50bP"
db ESC,"*p+10x.....*c3a50bP"
db ESC,"*p+11x+36Y",0
; ╗
hpc187 db ESC,"*p-11Y.....*c12a3bP"
db ESC,"*p+9X......*c3a25bP"
db ESC,"*p-9x-10Y..*c22a3bP"
db ESC,"*p+19X.....*c3a35bP"
db ESC,"*p+11x+21Y",0
; ╝
hpc188 db ESC,"*p+9x-36Y..*c3a18bP"
db ESC,"*p-9x+15Y..*c9a3bP"
db ESC,"*p+19x-15Y.*c3a28bP"
db ESC,"*p-19x+25Y.*c19a3bP"
db ESC,"*p+30x+11Y",0
; ╜
hpc189 db ESC,"*p-16Y.....*c22a3bP"
db ESC,"*p+9x-20Y..*c3a20bP"
db ESC,"*p+10X.....*c3a20bP"
db ESC,"*p+11x+36Y",0
; ╛
hpc190 db ESC,"*p+14x-36Y.*c3a28bP"
db ESC,"*p-14x+15Y.*c14a3bP"
db ESC,"*p+10Y.....*c14a3bP"
db ESC,"*p+30x+11Y",0
; ┐
hpc191 db ESC,"*p-16Y.....*c14a3bP"
db ESC,"*p+14X.....*c3a30bP"
db ESC,"*p+16x+16Y",0
; └
hpc192 db ESC,"*p+14x-16Y.*c16a3bP"
db ESC,"*p-20Y.....*c3a20bP"
db ESC,"*p+16x+36Y",0
; ┴
hpc193 db ESC,"*p-16Y.....*c30a3bP"
db ESC,"*p+14x-20Y.*c3a20bP"
db ESC,"*p+16x+36Y",0
; ┬
hpc194 db ESC,"*p-16Y.....*c30a3bP"
db ESC,"*p+14X.....*c3a30bP"
db ESC,"*p+16x+16Y",0
; ├
hpc195 db ESC,"*p+14x-36Y.*c3a50bP"
db ESC,"*p+3x+20Y..*c13a3bP"
db ESC,"*p+13x+16Y",0
; ─
hpc196 db ESC,"*p-16Y.....*c30a3bP"
db ESC,"*p+30x+16Y",0
; ┼
hpc197 db ESC,"*p-16Y.....*c30a3bP"
db ESC,"*p+14x-20Y.*c3a50bP"
db ESC,"*p+16x+36Y",0
; ╞
hpc198 db ESC,"*p+14x-36Y.*c3a50bP"
db ESC,"*p+3x+15Y..*c13a3bP"
db ESC,"*p+10Y.....*c13a3bP"
db ESC,"*p+13x+11Y",0
; ╟
hpc199 db ESC,"*p+9x-36Y..*c3a50bP"
db ESC,"*p+10X.....*c3a50bP"
db ESC,"*p+3x+20Y..*c8a3bP"
db ESC,"*p+8x+16Y",0
; ╚
hpc200 db ESC,"*p+9x-36Y..*c3a28bP"
db ESC,"*p+10X.....*c3a18bP"
db ESC,"*p+15Y.....*c11a3bP"
db ESC,"*p-10x+10Y.*c21a3bP"
db ESC,"*p+21x+11Y",0
; ╔
hpc201 db ESC,"*p+9x-21Y..*c3a35bP"
db "............*c21a3bP"
db ESC,"*p+10x+10Y.*c3a25bP"
db "............*c11a3bP"
db ESC,"*p+11x+11Y",0
; ╩
hpc202 db ESC,"*p-11Y.....*c30a3bP"
db ESC,"*p-10Y.....*c9a3bP"
db ESC,"*p+22X.....*c8a3bP"
db ESC,"*p-13x-15Y.*c3a18bP"
db ESC,"*p+10X.....*c3a18bP"
db ESC,"*p+11x+36Y",0
; ╦
hpc203 db ESC,"*p-21Y.....*c30a3bP"
db ESC,"*p+10Y.....*c9a3bP"
db ESC,"*p+19X.....*c11a3bP"
db ESC,"*p-10X.....*c3a25bP"
db ESC,"*p+10X.....*c3a25bP"
db ESC,"*p+11x+11Y",0
; ╠
hpc204 db ESC,"*p+9x-36Y..*c3a50bP"
db ESC,"*p+10X.....*c3a19bP"
db ESC,"*p+25Y.....*c3a25bP"
db ESC,"*p-10Y.....*c11a3bP"
db ESC,"*p+10Y.....*c11a3bP"
db ESC,"*p+11x+11Y",0
; ═
hpc205 db ESC,"*p-21Y.....*c30a3bP"
db ESC,"*p+10Y.....*c30a3bP"
db ESC,"*p+30x+11Y",0
; ╬
hpc206 db ESC,"*p+9x-36Y..*c3a18bP"
db ESC,"*p+25Y.....*c3a25bP"
db ESC,"*p+10x-25Y.*c3a18bP"
db ESC,"*p+25Y.....*c3a25bP"
db ESC,"*p-19x-10Y.*c12a3bP"
db ESC,"*p+19X.....*c11a3bP"
db ESC,"*p-19x+10Y.*c12a3bP"
db ESC,"*p+19X.....*c11a3bP"
db ESC,"*p+11x+11Y",0
; ╧
hpc207 db ESC,"*p-21Y.....*c30a3bP"
db ESC,"*p+10Y.....*c30a3bP"
db ESC,"*p+14x-25Y.*c3a15bP"
db ESC,"*p+16x+36Y",0
; ╨
hpc208 db ESC,"*p+9x-36Y..*c3a20bP"
db ESC,"*p+10X.....*c3a20bP"
db ESC,"*p-19x+20Y.*c30a3bP"
db ESC,"*p+30x+16Y",0
; ╤
hpc209 db ESC,"*p-21Y.....*c30a3bP"
db ESC,"*p+10Y.....*c30a3bP"
db ESC,"*p+14X.....*c3a25bP"
db ESC,"*p+16x+11Y",0
; ╥
hpc210 db ESC,"*p-16Y.....*c30a3bP"
db ESC,"*p+9X......*c3a35bP"
db ESC,"*p+10X.....*c3a35bP"
db ESC,"*p+11x+16Y",0
; ╙
hpc211 db ESC,"*p+9x-36Y..*c3a20bP"
db ESC,"*p+10X.....*c3a20bP"
db ESC,"*p-10x+20Y.*c21a3bP"
db ESC,"*p+21x+16Y",0
; ╘
hpc212 db ESC,"*p+14x-36Y.*c3a28bP"
db ESC,"*p+15Y.....*c21a3bP"
db ESC,"*p+10Y.....*c21a3bP"
db ESC,"*p+16x+11Y",0
; ╒
hpc213 db ESC,"*p+14x-21Y.*c3a35bP"
db "............*c16a3bP"
db ESC,"*p+10Y.....*c16a3bP"
db ESC,"*p+16x+11Y",0
; ╓
hpc214 db ESC,"*p+9x-16Y..*c3a35bP"
db "............*c21a3bP"
db ESC,"*p+10X.....*c3a35bP"
db ESC,"*p+11x+16Y",0
; ╫
hpc215 db ESC,"*p+9x-36Y..*c3a50bP"
db ESC,"*p+10X.....*c3a50bP"
db ESC,"*p-19x+20Y.*c30a3bP"
db ESC,"*p+30x+16Y",0
; ╪
hpc216 db ESC,"*p-21Y.....*c30a3bP"
db ESC,"*p+10Y.....*c30a3bP"
db ESC,"*p+14x-25Y.*c3a50bP"
db ESC,"*p+16x+36Y",0
; ┘
hpc217 db ESC,"*p-16Y.....*c14a3bP"
db ESC,"*p+14x-20Y.*c3a23bP"
db ESC,"*p+16x+36Y",0
; ┌
hpc218 db ESC,"*p+14x-16Y.*c16a3bP"
db "............*c3a30bP"
db ESC,"*p+16x+16Y",0
; █
hpc219 db ESC,"*p-36Y.....*c30a50bP"
db ESC,"*p+30x+36Y",0
; ▄
hpc220 db ESC,"*p-36Y.....*c30a25bP"
db ESC,"*p+30x+36Y",0
; ▌
hpc221 db ESC,"*p-36Y.....*c15a50bP"
db ESC,"*p+30x+36Y",0
; ▐
hpc222 db ESC,"*p+15x-36Y.*c15a50bP"
db ESC,"*p+15x+36Y",0
; ▀
hpc223 db ESC,"*p-11Y.....*c30a25bP"
db ESC,"*p+30x+11Y",0
; Positioning for bold face
b_1 db ESC,"*p-29x-1Y",0
b_2 db ESC,"*p-1x+1Y",0
;************************************************************************
;************** START OF HPFilter Code **********************************
;************************************************************************
MAIN proc far
HANDLER: jmp short HANDLEGO ; skip data
INSTALLED dw SIGNATURE
ACTIVE db 1 ; we are active
HANDLEGO:
mov cs:IN_CHAR,ax ; save incoming character
; Check for valid situation
;
; not active ?
cmp cs:ACTIVE, 1 ; are
jne PASSIT ; we're not running
; runing
; not print request ?
NXT_T: or ah, ah
je PROC_IT ; a print call
PASSIT:
pushf
call cs:BIOS_HANDLER
iret
;*****************************************************************************
;*****************************************************************************
; Now looking at all characters for the HPlj control strings
; and my own bold string control
PROC_IT:
push di
;---------------------------------------------------------------------------
; Did we find an ESCAPE ?
CK_ESC:
cmp al,ESC ;is it an ESC
jne CHK_CS ;no
mov cs:C_STRING,1 ;start control string
jmp EXIT_POP ;no more processing
;---------------------------------------------------------------------------
; Now check if we are in a Control_STRING
CHK_CS:
cmp cs:C_STRING,1 ; immed after ESC ?
jl NO_CS ; C_STRING = 0 --not in a control string
jg LG_CS ; C_STRING > 1
; in control string after ESC
cmp al,"G" ; Is it capital G ?
jne CHK_H ; no - check for 'off' code
mov cs:BOLD_ON,1
mov cs:C_STRING,0
jmp EXIT_POP
CHK_H: cmp al,"H"
jne PRT_ESC ;no - print the stored ESC
mov cs:BOLD_ON,0 ;yes - BOLDING off
mov cs:C_STRING,0
jmp EXIT_POP
;---------------------------------------------------------------------------
; Print the stacked ESC and procees
PRT_ESC:
mov ax,ESC ; print escape
pushf ; place flags on stack
call cs:BIOS_HANDLER ; an interrupt handler
mov ax,cs:IN_CHAR ; print character
;
; Now increment the C_STRING count
; check for the end of the control strings
LG_CS:
inc cs:C_STRING
; Is it a Capital letter ?
cmp al,41h ;'A'
jl NO_CS
cmp al,5Ah ;'Z'
jg NO_CS
;
; This is a capital letter
mov cs:C_STRING,0; ; C_STRING=0 = off
NO_CS:
; is the character a line grawing graphic
cmp al, 179 ; below line drawing
jl EXIT_PRNT ; not a graphics char
cmp al, 223 ; above line drawing
jg EXIT_PRNT ; not a graphics char
;==========================================================================
; we will process this one, save what we will need.
sub ah,ah ; zero high portion
sub al,179 ; adjust number down to 179 base
shl ax,1 ; left shift 1 = *2
add ax, offset HP_BASE ; al = base + offet = pointer to string
mov di,ax ; prepare to load pointer address
mov di,cs:[di] ; load pointer address
SLOOP1:
mov ah, 0 ;request print
mov al,byte ptr cs:[di] ; load a character
cmp al,0 ; is the char zero ?
je EXIT_SLOOP ; end of string
cmp al,'.' ; spaceing character
je SLINC ; skip it
pushf ; place flags on stack
call cs:BIOS_HANDLER ; an interrupt handler
SLINC: inc di ; next character
jmp sloop1
EXIT_SLOOP:
jmp EXIT_POP
; Substitution string has been sent.
;----------------------------------------------------------------------------
; Exit and print the character
EXIT_PRNT:
; Is BOLDING ON ?
cmp cs:BOLD_ON,1
jne PRINTIT ; NO !
; YES - print the character
mov ax,cs:IN_CHAR ;get the character
pushf
call cs:BIOS_HANDLER ;print it
; backup the cursor to +1x +1y for the past character printed
mov ax, offset b_1
mov di,ax
SLOOP2:
mov ah, 0 ;request print
mov al,byte ptr cs:[di] ; load a character
cmp al,0 ; is the char zero ?
je EXIT_SLOOP2 ; end of string
pushf ; place flags on stack
call cs:BIOS_HANDLER ; an interrupt handler
inc di ; next character
jmp sloop2
EXIT_SLOOP2:
; print the character again
mov ax,cs:IN_CHAR ;get the character
pushf
call cs:BIOS_HANDLER ;print it
; move cursor back to old position at end of single print
mov ax, offset b_2
mov di,ax
SLOOP3:
mov ah, 0 ;request print
mov al,byte ptr cs:[di] ; load a character
cmp al,0 ; is the char zero ?
je EXIT_SLOOP3 ; end of string
pushf ; place flags on stack
call cs:BIOS_HANDLER ; an interrupt handler
inc di ; next character
jmp sloop3
EXIT_SLOOP3:
jmp EXIT_POP
;-------------------------------------------------------------------------
PRINTIT:
pushf ; for iret satisfaction
call cs:BIOS_HANDLER ; an interrupt handler
EXIT_POP:
pop di
iret ; and return to caller
;---------------------------------------------------------------------------
END_CODE equ this byte ; last part of resident
;************************************************************************
; TRANSIENT PART
;************************************************************************
START: push ds
xor ax, ax
push ax ; .COM programs start like this
mov es, ax
mov si, PRINTER_INTERRUPT*4 ; point to installed address
lods word ptr es:[si]
mov word ptr BIOS_HANDLER, ax
lods word ptr es:[si]
mov word ptr BIOS_HANDLER+2, ax
les si, BIOS_HANDLER
cmp word ptr es:[si+2], SIGNATURE ; this us?
jne INSTALL ; not yet-- install us
; it is us, flop setting of active flag
mov al, es:[si+4] ; pick up running flag
xor al, 1 ; flip the bit
mov es:[si+4], al ; replace it
mov dx, offset m$RUNNING ; for now, assume it's running
cmp al, 1 ; were we right?
jz MSG_N_SPLIT ; yes, take this
mov dx, offset m$OFFNOW ; report "off"
; When we get here, DX is pointing to a status message. Print it and
; leave.
MSG_N_SPLIT: DOS PRINT_MESSAGE ; "print message" function
ret ; goodbye!
; If we get to this spot, it's the first time that the program has been
; run. Install our own handler into the interrupt vector, report this
; event with a message, and let DOS know we want to stay around.
INSTALL:
mov al, PRINTER_INTERRUPT ; printer interrupt, please
DOS SET_VECTOR HANDLER ; DOS function 25h is "set interrupt"
DOS PRINT_MESSAGE m$NOWREADY
; Everything's complete. Leave the program via INT 27H with DX pointing to
; the end of the resident part, and DOS'll keep the important stuff around
; while freeing up the memory occupied by the part that's not part of
; the interrupt handler per se.
mov dx, offset END_CODE+1 ; point to the end of the fixed part
int 27H ; end-but-stick-around
; Three status report messages.
m$NOWREADY db "HPFilter (BOLD & Lite lines) installed and running.$"
m$RUNNING db "HPFilter reactivated.$"
m$OFFNOW db "HPFilter temporarily deactivated.$"
MAIN endp
CSEG ends
end HOME